package com.jixiang.user.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jixiang.model.common.dtos.ResponseResult;
import com.jixiang.model.user.dtos.AdminUserDtos;
import com.jixiang.model.user.entity.UsAdress;
import com.jixiang.user.service.UsAdressService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * (UsAdress)表控制层
 *
 * @author makejava
 * @since 2023-11-04 23:20:16
 */
@RestController
@RequestMapping("address")
public class UsAdressController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private UsAdressService usAdressService;

    @ApiOperation("获取用户地址信息数据")
    @GetMapping("/appGetAddress")
    public ResponseResult appGetAddress(){
        return usAdressService.appGetAddress();
    }

    @ApiOperation("修改用户地址信息数据")
    @PostMapping("/appUpdateAddress")
    public ResponseResult appUpdateAddress(@RequestParam(required = true,value = "adrId")String adrId){
        return usAdressService.appUpdateAddress(adrId);
    }

    @ApiOperation("添加用户地址信息数据")
    @PostMapping("/appAddAdress")
    public ResponseResult appAddAdress(@RequestBody(required = true)UsAdress UsAdress){
        return usAdressService.appAddAdress(UsAdress);
    }

    @ApiOperation("微信获取用户全部地址信息")
    @GetMapping ("/wxAppGetwxUserAdr")
    public ResponseResult wxAppGetwxUserAdrData(){
        return usAdressService.wxAppGetwxUserAdrData();
    }

    @ApiOperation("微信获取用户ID地址信息")
    @GetMapping ("/wxAppGetwxUserAdrById")
    public ResponseResult wxAppGetwxUserAdrByIdData(@RequestParam(value = "id",required = true)Long id){
        UsAdress byId = usAdressService.getById(id);
        return ResponseResult.okResult(byId);
    }

    @ApiOperation("微信添加用户地址信息")
    @PostMapping ("/wxAppAddwxUserAdr")
    public ResponseResult wxAppAddwxUserAdrData(@RequestBody(required = true)UsAdress UsAdress){
        return usAdressService.wxAppAddwxUserAdrData(UsAdress);
    }

    @ApiOperation("微信删除用户地址信息")
    @PostMapping ("/wxAppDelwxUserAdr")
    public ResponseResult wxAppDelwxUserAdr(@RequestParam(required = true,value = "id")Long id){
//        boolean b = usAdressService.removeById(UsAdress.getId());
        boolean b = usAdressService.removeById(id);
        return ResponseResult.okResult("删除成功");
    }
}

